package org.vincen.springapp.domain.diogenes;

import java.io.Serializable;
import java.util.Collection;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(schema="diogenes", name="T_USER")
@Access(AccessType.FIELD)
@XmlRootElement(name="user")
@XmlAccessorType(XmlAccessType.FIELD)
public class User implements Serializable{

	private static final long serialVersionUID = 5352680306360296016L;

	@Id
	@Column(name="user_id")
	@SequenceGenerator(schema="diogenes", name="User_gen", sequenceName="USER_SEQ")
	@GeneratedValue(generator="User_gen")
	private Integer userId;
	@Column(name="user_name")
	@NotNull
	private String username;
	@Column(name="password")
	@XmlTransient
	private String password;
	@Column(name="real_name")
	private String realName;
	@Column(name="email")
	private String email;
	@Column(name="phone1")
	private String phone1;
	@Column(name="phone2")
	private String phone2;
	@ManyToMany(mappedBy="users", fetch=FetchType.EAGER)
	@XmlTransient
	@JsonIgnore
	private Collection<Department> departments;
	
	public User() {
		super();
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhone1() {
		return phone1;
	}

	public void setPhone1(String phone1) {
		this.phone1 = phone1;
	}

	public String getPhone2() {
		return phone2;
	}

	public void setPhone2(String phone2) {
		this.phone2 = phone2;
	}

	public Collection<Department> getDepartments() {
		return departments;
	}

	public void setDepartments(Collection<Department> departments) {
		this.departments = departments;
	}

	public Integer getUserId() {
		return userId;
	}

}
